package com.boot.sample.websocket.service;

import com.boot.sample.websocket.dbo.User;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class UserService {
    private static List<User> userList=new ArrayList<>();

    static {
        userList.add(new User("xiaohu","小虎"));
        userList.add(new User("liuli","刘利"));
        userList.add(new User("linlin","琳琳"));
    }

    public List<User> getAllUser(){
        List<User> users=new ArrayList<>(userList);
        return users;
    }

    public User getUserByUid(String uid){
        List<User> users=new ArrayList<>(userList);
        for (User user:users){
            if(user.getUid().equals(uid)){
                return user;
            }
        }
        return null;
    }
}
